<?php 

	class tune
	{
		var $sock;
		
		function __construct($tune_string = null)
		{
            include('sock.php');
            $this->sock = new sock;
			$this->sock->open_socket('137.140.8.82');
			$station = $_GET['station'];
			if($tune_string == null)
				$r = $this->tune_now($station);
			else
				$r = $this->tune_later($tune_string);
			include('views/tune.php');
			$this->sock->close_socket();
		}
		
		function tune_now($station)
		{
			$current_date_time = "R,".date('i,G,j,n,Y');
			$r = $this->sock->send_data_packet($current_date_time.",".$station);
			return $r;
		}
		
		function tune_later($tune_string)
		{
			$r = $this->sock->send_data_packet($tune_string);
			include('controllers/database_controller.php');
			$database = new database();
			$database->connect_database();
			$database->select_database();
			$database->schedule_tune($_SESSION['email'],$_GET['date'],$_GET['station']);
			return $r;
		}
	}

?>